<?php

  session_start();
  
  include_once("./jpgraph-1.17/src/jpgraph.php");
  include_once("./jpgraph-1.17/src/jpgraph_pie.php");
  header('Content-type: image/jpg');
  //echo "here we are...";

  $index = $_GET["index"];
  //let's make a graph of the stuff the user has in the system
  $graph = new PieGraph(350,200,"auto");
  $graph->SetShadow();
  $graph->title->Set($_SESSION["pieGraph"]["{$index}"]["title"]);
  $graph->title->SetFont(FF_FONT1,FS_BOLD);

  $p1 = new PiePlot($_SESSION["pieGraph"]["{$index}"]["data"]);
  //$p1 = new PiePlot(array(1));
  //move to make room for legend?
  $p1->SetCenter(0.35,0.5);

  $p1->ShowBorder(false);

  $p1->value->SetFont(FF_FONT1,FS_BOLD);
  $p1->value->SetColor("darkred");

  $p1->SetLabelType(PIE_VALUE_ABS);

  //label format?
  $p1->value->SetFormat("");
  //$p1->value->Show();

  //size of pie on fraction of width of graph
  $p1->SetSize(0.3);

  //legends
  //$p1->SetLegends(array("Waiting (%d)","On hold (%d)","Executing (%d)"));
  $p1->SetLegends($_SESSION["pieGraph"]["{$index}"]["legend"]);
  // $p1->SetSliceColors(array('red', 'blue'));
  $p1->SetSliceColors(array('red', 'blue', 'green', 'yellow', 'darkorchid1', 'cyan', 'gold'));
  $graph->legend->Pos(0.05,0.15);

  $graph->Add($p1);
  $graph->Stroke();

?>
